<template>
    <div>
        <h1>我是index页面</h1>
        <a @click="changeRoute('pageB')">跳转pageB子路由</a>
        <a @click="changeRoute('pageC')">跳转pageC子路由</a>
        <router-view></router-view>
        <button @click="add">加1</button>
        <h2>vuex共享数据计数器的值：{{count}}</h2>
    </div>
</template>

<script>
    export default {
        computed: {
            count() {
                return this.$store.state.count
            }
        },
        methods: {
            changeRoute(name) {
                this.$router.push({name})
            },
            add(){
                this.$store.commit('increment')
            }
        }
    }
</script>

<style lang="scss" scoped>
a{
    color: #169DFA;
    margin-right: 20px;
}
</style>
